package cn.iocoder.yudao.module.fengdong.smartelderly.dal.mysql.buyrecord;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.fengdong.smartelderly.dal.dataobject.buyrecord.BuyRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.fengdong.smartelderly.controller.admin.buyrecord.vo.*;

/**
 * 购买记录 Mapper
 *
 * @author 沣东养老院管理员
 */
@Mapper
public interface BuyRecordMapper extends BaseMapperX<BuyRecordDO> {

    default PageResult<BuyRecordDO> selectPage(BuyRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BuyRecordDO>()
                .eqIfPresent(BuyRecordDO::getCommodityId, reqVO.getCommodityId())
                .eqIfPresent(BuyRecordDO::getName, reqVO.getName())
                .eqIfPresent(BuyRecordDO::getMobile, reqVO.getMobile())
                .eqIfPresent(BuyRecordDO::getDetailAddress, reqVO.getDetailAddress())
                .likeIfPresent(BuyRecordDO::getOldmanName, reqVO.getOldmanName())
                .likeIfPresent(BuyRecordDO::getOrderNumber, reqVO.getOrderNumber())
                .eqIfPresent(BuyRecordDO::getOldmanCard, reqVO.getOldmanCard())
                .eqIfPresent(BuyRecordDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(BuyRecordDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(BuyRecordDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(BuyRecordDO::getEndTime, reqVO.getEndTime())
                .orderByDesc(BuyRecordDO::getId));
    }

    default List<BuyRecordDO> selectList(BuyRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BuyRecordDO>()
                .eqIfPresent(BuyRecordDO::getCommodityId, reqVO.getCommodityId())
                .eqIfPresent(BuyRecordDO::getName, reqVO.getName())
                .eqIfPresent(BuyRecordDO::getMobile, reqVO.getMobile())
                .eqIfPresent(BuyRecordDO::getDetailAddress, reqVO.getDetailAddress())
                .likeIfPresent(BuyRecordDO::getOldmanName, reqVO.getOldmanName())
                .eqIfPresent(BuyRecordDO::getOldmanCard, reqVO.getOldmanCard())
                .eqIfPresent(BuyRecordDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(BuyRecordDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(BuyRecordDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(BuyRecordDO::getEndTime, reqVO.getEndTime())
                .orderByDesc(BuyRecordDO::getId));
    }

}
